package com.example.demo.controller;

import com.example.demo.model.ResposeModel;
import com.example.demo.service.PlatAreaService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/*区域*/
@Controller
@RequestMapping("/api/PlatArea")
public class PlatAreaController {
	private Logger log = LoggerFactory.getLogger(PlatAreaController.class);
	@Autowired
	private PlatAreaService platAreaService;

	@RequestMapping("/getCities")
	@ResponseBody
	public ResposeModel getCities() {
		ResposeModel res = new ResposeModel();
		try {
			res.setData(platAreaService.getCities());
		} catch (Exception e) {
			res.setStatus("0");
			res.setMsg("获取数据出错");
		}

		return res;
	}
	
	@RequestMapping("/getDistricts/parentId/{parentId}")
	@ResponseBody
	public ResposeModel getDistricts(@PathVariable("parentId") Integer parentId) {
		ResposeModel res = new ResposeModel();
		try {
			res.setData(platAreaService.getDistricts(parentId));
		} catch (Exception e) {
			res.setStatus("0");
			res.setMsg("获取数据出错");
		}

		return res;
	}

}
